#include "mypushbutton.h"
#include<QPropertyAnimation>
MyPushButton::MyPushButton(QString normalImg,QString pressImg)
{
this->normalImgPath = normalImg;
    this->pressImgPath = pressImg;

    QPixmap pix;
   bool ret = pix.load(this->normalImgPath);
    if(!ret)
    {
        QString str = QString("%1 图片加载失败").arg(this->normalImgPath);
        qDebug () <<str;
        return;
    }
      this->setFixedSize(pix.width(),pix.height());
    this->setStyleSheet("QPushButton{border:1px;}");
    this->setIcon(pix);
    this->setIconSize(QSize(pix.width(),pix.height()));
}
void MyPushButton::Zoom1()
{
  QPropertyAnimation * animation = new   QPropertyAnimation(this,"geometry");
  animation->setDuration(200);
  animation->setStartValue(QRect(this->x(),this->y(),this->width(),this->height() ));
  animation->setEndValue(QRect(this->x(),this->y()+10,this->width(),this->height() ));
  animation->setEasingCurve(QEasingCurve::OutBounce);
  animation->start();
};
void MyPushButton::Zoom2()
{
    QPropertyAnimation * animation = new   QPropertyAnimation(this,"geometry");
    animation->setDuration(200);
    animation->setStartValue(QRect(this->x(),this->y()+10,this->width(),this->height() ));
    animation->setEndValue(QRect(this->x(),this->y(),this->width(),this->height() ));
    animation->setEasingCurve(QEasingCurve::OutBounce);
    animation->start();
};
